<?                     
/*                                                                                                                               
    This PHP script is licensed under the GPL                      

    Author: Terence Yim                      
    E-mail: chtyim@gmail.com                      
    Homepage: http://web-news.sourceforge.net                      
*/                      
   

set_time_limit(120);        

             
$execution_start_index = time();                                                                                                            
define ("EDITOR_NAME", "nntpeditor");                 
define ("RESULT_PAGE_SIZE", 1000);                     
define ("APPLICATION_NAME", "NewsJet Usenet Browser");                     
define ("DEFAULT_IMAGE_FONT", "/homepages/13/d97505132/htdocs/webservices/fonts/verdanab.ttf");                     
define ("CACHE_PATH", "data/temp/");                     
define ("PROFILE_PATH", "profile/");                     
define ("CACHE_AGE_LIMIT", 259200);                     
define ("CACHE_MAX_LINE_COUNT", 35);                    
define ("SEARCH_BUTTON", "images/go-orange-trans.gif");        
define ("PROFILE_NAME", "madsadynntpprasasdfofile");                      

                      
$preview_temp = array                     
 (                         
     "alt.binaries.pictures.automobile",                     
     "alt.binaries.pictures.movie-posters",                     
     "alt.binaries.pictures.sports",                     
     "alt.binaries.pictures.fantasy-sci-fi",                      
     "alt.binaries.pictures.bluebird",                      
     "alt.binaries.photos.original",                       
     "alt.binaries.pictures.supermodels",                          
     "alt.binaries.pictures.autos.oldtimers",                     
     "alt.binaries.pictures.wallpaper",                      
     "alt.magazine.playboy",                      
     "alt.binaries.pictures.bikini.central"                     
 );      
  
$categories = array (                     
                    "Pictures"=>array(                     
                           "images-west.usenet.com",                     
                           "/.*(picture|photo)(.*)\s+(\d+)\s+(\d{3,9})\s+/"),                     
                    "Movies"=>array(                     
                           "news-west.usenet.com",                     
                           "/.*(film|movies|multimedia|dvdr*|s*vcd)(.*)\s+(\d+)\s+(\d{3,9})\s+/") ,                       
                    "Music"=>array(                     
                           "mp3-west.usenet.com",                     
                            "/alt.binaries\.+(sounds)*\.+mp3.*\.+(\w+)?\s+(\d+)\s+(\d{3,9})\s+/" )                       
                );    
                 
# REMOVE OLD FILES                     
# --------------------------------------------------------------'                     
$old   = array ();      
$old[] = array ("name"=>"asset","regex"=>"/(.*)/i","limit"=>CACHE_AGE_LIMIT);   
$old[] = array ("name"=>".","regex"=>"/(.*)/i","limit"=>86400);   
$old[] = array ("name"=>"..","regex"=>"/(.*)/i","limit"=>86400);   
$old[] = array ("name"=>"idx","regex"=>"/(.*)/i","limit"=>86400*5);   
$old[] = array ("name"=>"error","regex"=>"/(.*)/i","limit"=>86400);   
$old[] = array ("name"=>"pointer","regex"=>"/(.*)/i","limit"=>CACHE_AGE_LIMIT);      
           
foreach ($old as $o) 
{ 
    $dir = CACHE_PATH . $o["name"];                       
    $arr = array();                     
    if (is_dir($dir))                      
    { # remove any files on the server that are older than 4 hours                     
       if ($dh = opendir($dir))                      
       {                     
           while (($file = readdir($dh)) !== false)                      
           {                      
               if (preg_match ($o["regex"], $file, $tmp))                     
               {                        
                   $diff = time() - filemtime($dir."/".$file);                     
                   if ($diff>$o["limit"])                     
                   {                     
                       unlink ($dir."/".$file);                     
                   }                      
               }                     
           }                     
           closedir($dh);                     
       }                     
    }  
} 
                     
# --------------------------------------------------------------'                     
  
include("class/cprofile.php"); 
#eval ($___debugger->attach_debugger("/homepages/13/d97505132/htdocs/nntp/class/cprofile.php"));  
/* INCLUDE replaced with debugger call */ 

#eval ($___debugger->attach_debugger("/homepages/13/d97505132/htdocs/nntp/class/cnavigator.php")); 
 include("class/cnavigator.php"); /* INCLUDE replaced with debugger call */   

include("addon/elements.php");                      
     
 include("addon/events.php"); 
#eval ($___debugger->attach_debugger("/homepages/13/d97505132/htdocs/nntp/addon/events.php"));  /* INCLUDE replaced with debugger call */ 

 include("webnews/nntp.php"); 
#eval ($___debugger->attach_debugger("/homepages/13/d97505132/htdocs/nntp/webnews/nntp.php"));  /* INCLUDE replaced with debugger call */     

include("config/webnews.cfg.php");      


$href                        = $_SERVER['SCRIPT_NAME'];                     
$qs                          = $_SERVER['QUERY_STRING'];                     
$host                        = $_SERVER["REMOTE_ADDR"];    

$pp_newsserver               = $_POST["newsserver"];                     
$pp_username                 = $_POST["username"];                     
$pp_password                 = $_POST["password"];                     
$pp_subscribe                = $_POST["subscribe"];                      
$pp_searchall                = $_POST["searchall"];                       
$pp_nzbdownload              = $_POST["dlnzb"];                        
$pp_nzbfilename              = $_POST["dlname"];        

$gg                          = $_GET["txtgroupname"];                     
$m                           = $_GET["message_id"];                      
$info                        = $_GET["i"];                      
$info_more                   = $_GET["im"];                     
$new_folder                  = $_GET["folder"];                     
$nav_folder                  = $_GET["bkf"];                     
$group_name                  = $_GET["g"];                      
$art_group                   = $_GET["art_group"];                      
$search_param                = $_GET["fi"];                     
$find_name                   = get_request("f");                      
$start_at                    = $_GET["s"];                      
$ps                          = $_GET["ps"];                      
$start_id                    = $_GET["k"];                      
$action                      = $_GET["a"];                     
$sub                         = $_GET["sub"];                     
$rep_server                  = $_GET["nntp"];                     
$super_search                = $_POST["fe"];                     
$bcount                      = false;                      
$breadcrumb                  = "";                     
$breaddata                   = array();                     
$cancel_event                = false;                     

$cookie_profile              = $_COOKIE[PROFILE_NAME];                     
$cookie_folders              = $_COOKIE["folders"];                     
$cookie_bookmark             = $_COOKIE["bookmark"];                     
$cookie_preview              = $_COOKIE["preview"];                     
$cookie_subscribed           = $_COOKIE["subscribed"];                     
$cookie_thumbnail_size       = $_COOKIE["thumbnail_size"];                     
$cookie_nntp_config          = $_COOKIE["nntp_config"];                     
$editor                      = $_COOKIE[EDITOR_NAME];    
   

$page_handler = new CNavigator();  
$user_profile = new CProfile();  

if ($m.$art_group.$find_name.$sub==""&&strpos($href,"profile")===false) 
{ 
    if (isset($_GET["g"]) && ! isset($_GET["fi"]) && ! isset($_GET["u"]))                          
    {                          
        $page_handler->set_selected_group($group_name,$action);                          
    }                     
    else                        
    {                          
        $group = $page_handler->get_selected_group();  
        if ($group)   
        {    
            $group_name = $group; 
            $handle = array ("s"=>"page", "fi"=>"param", "v"=>"view", "u"=>"user");   
            while (list($a,$b)=each ($handle)) 
            { 
                if (isset($_GET[$a])) 
                { 
                    $page_handler->set_attribute ($b, $_GET[$a]); 
                } 
            }   
            $start_at        = $page_handler->get_attribute ("page");  
            $search_param    = $page_handler->get_attribute ("param");  
            $search_user     = $page_handler->get_attribute ("user");   
            $cookie_preview  = $page_handler->get_attribute ("view");      
        }                          
    }    
} 
else if ($sub=="book") 
{ 
    if (isset($_GET["bkf"]))                          
    {                          
        $page_handler->set_selected_folder($nav_folder);                          
    }   
    $nav_folder = $page_handler->get_selected_folder();   
}  
else if ($sub=="all") 
{ 
    if (strlen($find_name) > 0)                          
    {                          
        $page_handler->set_selected_folder($find_name, "search", "sub=all");                          
    }   
    $find_name = $page_handler->get_selected_folder("search");   
}  

if (strlen($gg)>0)                     
{                      
    header('Location: ' . $href . '?g=' . $gg);                        
    exit;                     
}                     
if (strlen($pp_nzbdownload)>0)                     
{                      
    header('Content-Disposition: attachment; filename="'.$pp_nzbfilename.'"');                       
    print stripslashes( $pp_nzbdownload );                     
    exit;                     
}                     

switch ($action)  
{ 
    case "folder":  
        $user_profile->add_bookmark_folder($new_folder);    
        $qu = preg_replace("/[&?]*a=(\w+)/", "", $qs);                       
        response_redirect ($href."?" . $qu);   
        break; 
    case "topup":  
        $user_profile->clear_bytes_loaded(); 
        break; 
    case "bookmark":  
        include ("dialog/favorites.htm"); 
        break; 
    case "search": 
        include ("addon/search.php"); 
        break; 
    case "dbook": 
        $user_profile->remove_bookmark($_GET["bkdir"], $_GET["k"]);  
        break; 
    case "rename.folder": 
        $user_profile->rename_folder($_GET["old"],$_GET["new"]);  
        response_redirect ($href . "?sub=book&bkf=" . $_GET["new"] ); 
        break; 
    case "close.ex": 
        $page_handler->close($_GET["e"]);  
        break; 
    case "changesort": 
        cc_toggle_cookie ("listsort", "group", "size");    
        break; 
    case "changeview": 
        cc_toggle_cookie ("listview", "list", "thumbnail");      
        break; 
    case "preview": 
        cc_toggle_cookie ("preview", "preview", "nopreview"); 
        break; 
    case "update.group": 
        unlink ($_GET["f"]);     
        response_redirect ("$href?g=$group_name");     
        break; 
    case "bevel2": 
        imageroundedrectangle ($_GET["w"],$_GET["h"],$_GET["c"]);   
        break; 
    case "bevel": 
        bevel ("",$_GET["c"],$_GET["w"],$_GET["h"]); 
        break; 
    case "email": 
        if (strpos($qs,"kl")===false) 
        { 
            window_open ($href . "?" . $qs . "&kl=kl", 500, 400, "no", "email_window") ;    
        } 
        break; 
    case "subscribe": /* no "break" so it falls thru to unsubscribe */ 
    case "unsubscribe": 
        $user_profile->group_subscribe($group_name, $action);    
        break;  
    case "slide": 
        if (strpos($qs,"kl")===false) 
        { 
            window_open ($href . "?" . $qs . "&kl=kl", 800, 550, "yes", "preview_window") ;   
        } 
        break;  
}  
                      
$sg_c = $user_profile->get_subscribed_groups();                    
if ($start_at=="")                      
{                      
    $start_at=0;                      
}                        

if (strlen($rep_server)>0)                     
{                      
    $nntp_server   = $rep_server;                       
}                     

$user = "1053900012"; 
$pass = "cyber8"; 

// NEWSGROUP LOGIN/CONFIG FORM                     
// -----------------------------------------------------------------------'        
include ("addon/process.php");                                     
                                                   
$title_color   = "#9A970E";                     
$sidebar_over  = "#F7E8AF";                     
$sidebar_text  = "#ffffff";                     
$sidebar_color = "#FFFCA8";                     
$toolbar_color = "#9A610E";                     
$strip_color   = "#F7F5AF";                     
$h1_text       = "#A88400";                     
$thumbnail_bg  = "#F7F5AF";                             


for ($e=0;$e<count($sg_c);$e++)                     
{                     
    $s=$sg_c[$e];                                      
     if ($s!="" && array_search($s, $preview_temp)===false && (strpos($s,"picture") !== false || strpos($s,"photo") !== false))                     
   {                     
        $value            = $preview_temp[$e];                     
        $preview_temp[$e] = $s;                     
        $preview_temp[]   = $value;                     
    }                     
}                                     
?> 